package com.qijian.maindata.domain.query;

import com.baomidou.mybatisplus.annotation.TableName;
import com.qijian.common.utils.mybatis.WhereType;
import com.qijian.common.utils.mybatis.WhereTypeEnum;
import lombok.Data;
import lombok.ToString;

import java.util.Date;
import java.util.List;

@Data
@ToString
@TableName("main_quality_performance_flow")
public class QualityPerformanceFlowQuery {

    @WhereType(filed = "id",type = WhereTypeEnum.IN)
    private List<Long> ids;

    @WhereType(filed = "id")
    private Long id;

    @WhereType(filed = "number",type = WhereTypeEnum.LIKE)
    private String number;

    @WhereType(filed = "apply_name",type = WhereTypeEnum.LIKE)
    private String applyName;

    @WhereType(filed = "apply_dept_name",type = WhereTypeEnum.LIKE)
    private String applyDeptName;

    @WhereType(filed = "title",type = WhereTypeEnum.LIKE)
    private String title;

    //排序
    @WhereType(filed = "update_time",sort = true,type = WhereTypeEnum.DESC)
    private Date updateTime;


    // 流程相关查询
    @WhereType(ignore= true)
    private List<String> approvalStatus;

    @WhereType(tableName = "main_flow", filed = "approval_status" ,type = WhereTypeEnum.IN)
    private List<String> approve;


    @WhereType(func = "EXISTS (select 1 from t_flowable_record f inner join main_flow m on f.source_id = m.id  " +
            "       where m.target_dept_id = main_quality_performance_flow.id " +
            "       and f.business_key= 'flow_quality_craft_dispatch' and f.user_id ={1})")
    private Long u;


    @WhereType(func = "EXISTS (select 1 from t_flowable_record f left join ACT_RU_TASK ru on ru.PROC_INST_ID_=f.process_instance_id " +
            "inner join ACT_HI_IDENTITYLINK i on i.TASK_ID_=ru.ID_ " +
            " where main_quality_performance_flow.id = f.source_id and f.business_key= 'flow_quality_craft_dispatch'  and ( ru.ASSIGNEE_ ={1} or i.USER_ID_ = {1} ))")
    private Long i;

    @WhereType(deptTableName = "sys_user", userTableName = "sys_user")
    private Boolean dataScope;


    @WhereType(fields = {"main_quality_performance_flow.title","main_quality_performance_flow.number","main_quality_performance_flow.apply_name","main_quality_performance_flow.apply_dept_name"},type = WhereTypeEnum.LIKE)
    private String condition;

}
